<!DOCTYPE html>
<html>
<head>
    <meta charset='UTF-8'>
    <title>姓名案例-计算属性</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div  id="root">
        姓：<input type="text" v-model="xing"><br/><br/>
        名：<input type="text" v-model="ming"><br/><br/>
        姓名：<span>{{fullName}}</span> <br/> <br/>
    </div>
</body>
<!--   JS   -->
    <script>
        const vm = new Vue({
            el:'#root',
            data:{
                xing:'王',
                ming:'漂亮',
                fullName:'王漂亮'
            },
            watch:{
                xing(value){
                    setTimeout(() => {
                        this.fullName = value +'-'+ this.ming
                    }, 1000);
                },
                ming(value){
                    this.fullName = this.xing + '-'+ value
                }
            }
        })
    </script>
</html>